<?php
namespace App\Admin\Controllers;
use App\Http\Controllers\Controller;
use Dcat\Admin\FormStep\Form as StepForm;
use App\Models\InputStepForm;
use Dcat\Admin\Form;
use Dcat\Admin\Admin;
use Dcat\Admin\Layout\Content;
use Illuminate\Http\Request;
use Log;
// use Dcat\Admin\Widgets\Form;
class InputStepFormController extends Controller
{
    protected $options = [
        1 => '显示文本框',
        2 => '显示编辑器',
        3 => '显示文件上传',
        4 => '还是显示文本框',
    ];
    // use PreviewCode;
    public function index(Content $content)
    {
        return $content
            // ->body('<div style="margin:5px 0 15px;">'.$this->buildPreviewButton().'</div>')
            ->body($this->form())
            ->header('电除尘信息采集清单录入');
            // ->description('分步表单DEMO');
    }
    protected function form()
{
    Admin::js('/stepform/js/jquery.smartWizard.min.js');
    Admin::css('/stepform/css/step.css');
    return Form::make(new InputStepForm(), function (Form $form) {
            $form->title('分步表单');
            $form->action('step');
            $form->disableListButton();
            $form->multipleSteps()
                ->remember() 
                ->width('100%')
                ->add('工艺设备信息', function (StepForm $step) use ($form) {
                    $step->text('projectName',trans('项目名称'))->required();
                    $step->text('p1a',trans('设计处理烟气量(工况m3/h)'))->required();
                    $step->text('p1b',trans('设计烟气温度（℃）'))->required();
                    $step->text('p1f',trans('脱硫剂'))->required();
                    $step->radio('p1c','工艺设备类型')->options(
                        ['烧结机头' => '烧结机头','烧结机尾' => '烧结机尾','蒸汽锅炉' => '蒸汽锅炉',
                        '电力锅炉' => '电力锅炉','转炉' => '转炉','其他' => '其他']
                    )->when('烧结机头', function ($step) {
                        $step->text('p1ca','m2烧结');
                    })->when('其他', function ($step) {
                        $step->text('p1cb','其他');
                    })->when('蒸汽锅炉', function ($step) {
                        $step->text('p1cd','t/h机组');
                    })->when('转炉', function ($step) {
                        $step->text('p1ce','t转炉');
                    })->when('电力锅炉', function ($step) {
                        $step->text('p1cf','MW机组');
                    });
                    $step->radio('p1d','脱硝工艺')->options(
                        ['SNCR' => 'SNCR','SCR' => 'SCR','臭氧脱硝' => '臭氧脱硝','其他' => '其他']
                    );
                    $step->radio('p1e','脱硫工艺')->options(
                        ['炉内脱硫' => '炉内脱硫','湿法脱硫' => '湿法脱硫','干法脱硫' => '干法脱硫',
                        '半干法脱硫' => '半干法脱硫','无脱硫' => '无脱硫','其他' => '其他']
                    );
                })
                ->add('电除尘器设计参数一', function (StepForm $step) use ($form){
                    // $step->text('p2b',trans('建设时间'),'left');
                    $step->text('p2c',trans('列数(台数)'),'left')->required();
                    $step->text('p2d',trans('室数(个)'),'left')->required();
                    $step->text('p2e',trans('电场数(个)'),'left')->required();
                    $step->text('p2f',trans('同极间距(mm)'),'left')->required();
                    $step->text('p2g',trans('电场有效高度(mm),单位为:mm'),'left')->required()->help('<i style="color:red">注意:单位为mm</i>');
                    $step->text('p2i',trans('处理烟气量(工况)(m3/h)'),'left')->required();
                    $step->text('p2u',trans('单室横向灰斗数'));
                    $step->text('p2j',trans('出口粉尘浓度(mg/Nm3)'),'left');
                    $step->text('p2k',trans('建设本体厂家名称'));
                    $step->text('p2y',trans('高压电源厂家'));
                    $a31 = [
                        '双层卸灰阀' => '双层卸灰阀',
                        '形式卸灰阀' => '形式卸灰阀',
                        '电动插板阀' => '电动插板阀',
                        '球形阀（配合气力输送泵）' => '球形阀（配合气力输送泵）',
                        '无' => '无',
                    ];
                    $a3x = [
                        '侧部大框架+悬挂小框架(宣化形式)' => '侧部大框架+悬挂小框架(宣化形式)',
                        '侧部刚性大框架性小框架(菲达形式)' => '侧部刚性大框架性小框架(菲达形式)',
                        '顶部吊梁+鱼骨型小框架(龙净形式)' => '顶部吊梁+鱼骨型小框架(龙净形式)'
                    ];
                    $step->select('p2r',trans('阴极结构形式'))->options($a3x);
                    
                    $step->select('p2v',trans('卸灰阀形式（卸灰时频繁工作装置）'))->options($a31);
                    $a32 = [
                        '刮板机' => '刮板机',
                        '螺旋输送机' => '螺旋输送机',
                        '气力输送' => '气力输送'
                    ];
                    $step->select('p2w',trans('输灰方式'))->options($a32);
                    $a33 = [
                        '单相工频' => '单相工频',
                        '三相工频' => '三相工频',
                        '高频电源' => '高频电源',
                        '高频+脉冲' => '高频+脉冲',
                        '变频脉冲' => '变频脉冲',
                        '高频恒流' => '高频恒流',
                        '工频恒流' => '工频恒流',
                    ];
                    $a3w = [
                        'C480' => 'C480',
                        'BE' => 'BE',
                        'C390' => 'C390' ,
                        'C818' => 'C818' ,
                        'ZT24' => 'ZT24' ,
                        '其他' => '其他' ,
                    ];
                    $step->select('p2l',trans('极板形式'),'left')->options($a3w);
                    $step->select('p2x',trans('输灰方式'))->options($a33);
                    $step->table('p2h', trans('各电场阴极排数(通道数/排) 与 有效长度'),function ($table) {
                        $table->text('电场名称')->required();
                        $table->text('排数')->required();
                        $table->text('有效长度(m)')->required()->help('<i style="color:red">注意:单位为m</i>');
                    })->rules('required');
                    
                })
                ->add('电除尘器设计参数二',function($step){
                    $step->radio('p2p',trans('阴极振打层数'))->options(['1' => '1层','2' => '2层','3' => '3层','4' => '其他'])
                        ->when('1',function(StepForm $step){

                            $step->radio('yangjzdxs','阳极振打形式')->options(
                                ['顶部电磁锤振打' => '顶部电磁锤振打','底部绕臂锤振打' => '底部绕臂锤振打','顶部绕臂锤底部绕臂锤振打' => '顶部绕臂锤+底部绕臂锤振打']
                            )->when('底部绕臂锤振打',function(StepForm $step){
                                $step->table('yjzdsx', trans('阳极振打时序'),function ($table) {
                                    $table->text('电场阳打延迟时间(s)');
                                    $table->text('电场阳打运行时间(s)');
                                    $table->text('电场阳打停止时间(s)');
                                })->rules('required');
                            })->when('顶部绕臂锤底部绕臂锤振打',function(StepForm $step){
                                $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                    $table->text('电场上阳打延迟时间(s)');
                                    $table->text('电场上阳打运行时间(s)');
                                    $table->text('电场上阳打停止时间(s)');
                                    $table->text('电场下阳打延迟时间(s)');
                                    $table->text('电场下阳打运行时间(s)');
                                    $table->text('电场下阳打停止时间(s)');
                                })->rules('required');
                            })->default('顶部电磁锤振打');

                            $step->radio('yinjzdxs','阴极振打形式')->options(
                                ['顶部电磁锤振打' => '顶部电磁锤振打','顶部传动侧部绕臂锤振打' => '顶部传动+侧部绕臂锤振打','侧部传动侧部绕臂锤振打' => '侧部传动+侧部绕臂锤振打','空气振打锤'=>'空气振打锤']
                            )->when('顶部传动侧部绕臂锤振打',function(StepForm $step){

                                $step->table('yjzdsx', trans('阴极振打时序'),function ($table) {
                                    $table->text('电场阴极振打延迟时间(s)');
                                    $table->text('电场阴极振打运行时间(s)');
                                    $table->text('电场阴极振打停止时间(s)');
                                })->rules('required');

                                $step->table('yinjzdjr', trans('阴极振打传动加热控制设置'),function ($table) {
                                    $table->text('电场转轴箱温度上限(℃)');
                                    $table->text('电场转轴箱温度下限(℃)');
                                })->rules('required');
                                
                            })->when('侧部传动侧部绕臂锤振打',function(StepForm $step){

                                $step->table('yinjzdjr', trans('阴极振打传动加热控制设置'),function ($table) {
                                    $table->text('电场转轴箱温度上限(℃)');
                                    $table->text('电场转轴箱温度下限(℃)');
                                })->rules('required');

                            })->default('顶部电磁锤振打');

                    })->when('2',function(StepForm $step){

                        $step->radio('yangjzdxs','阳极振打形式')->options(
                            ['顶部电磁锤振打' => '顶部电磁锤振打','底部绕臂锤振打' => '底部绕臂锤振打','顶部绕臂锤底部绕臂锤振打' => '顶部绕臂锤+底部绕臂锤振打']
                        )->when('底部绕臂锤振打',function(StepForm $step){
                            $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                $table->text('电场阳打延迟时间(s)');
                                $table->text('电场阳打运行时间(s)');
                                $table->text('电场阳打停止时间(s)');
                            })->rules('required');
                        })->when('顶部绕臂锤底部绕臂锤振打',function(StepForm $step){
                            $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                $table->text('电场上阳打延迟时间(s)');
                                $table->text('电场上阳打运行时间(s)');
                                $table->text('电场上阳打停止时间(s)');
                                $table->text('电场下阳打延迟时间(s)');
                                $table->text('电场下阳打运行时间(s)');
                                $table->text('电场下阳打停止时间(s)');
                            })->rules('required');
                        })->default('顶部电磁锤振打');

                        $step->radio('yinjzdxs','阴极振打形式')->options(
                            ['顶部电磁锤振打' => '顶部电磁锤振打','顶部传动侧部绕臂锤振打' => '顶部传动+侧部绕臂锤振打','侧部传动侧部绕臂锤振打' => '侧部传动+侧部绕臂锤振打','空气振打锤'=>'空气振打锤']
                        )->when('顶部传动侧部绕臂锤振打',function(StepForm $step){

                            $step->table('yinjzdjr1', trans('阴极振打传动加热控制设置'),function ($table) {
                                $table->text('电场上转轴箱温度上限1(℃)');
                                $table->text('电场上转轴箱温度下限2(℃)');
                                $table->text('电场下转轴箱温度上限3(℃)');
                                $table->text('电场下转轴箱温度下限4(℃)');
                            })->rules('required');

                        })->when('侧部传动侧部绕臂锤振打',function(StepForm $step){

                            $step->table('yinjzdsx', trans('阴极振打时序'),function ($table) {
                                $table->text('电场上阴打延迟时间(s)');
                                $table->text('电场上阴打运行时间(s)');
                                $table->text('电场上阴打停止时间(s)');
                                $table->text('电场下阴打延迟时间(s)');
                                $table->text('电场下阴打运行时间(s)');
                                $table->text('电场下阴打停止时间(s)');
                            })->rules('required');
                            $step->table('yinjzdjr', trans('阴极振打传动加热控制设置'),function ($table) {
                                $table->text('电场转轴箱温度上限5(℃)');
                                $table->text('电场转轴箱温度下限5(℃)');
                            })->rules('required');
                            

                        })->default('顶部电磁锤振打');

                    })->when('3',function(StepForm $step){

                        $step->radio('yangjzdxs','阳极振打形式')->options(
                            ['顶部电磁锤振打' => '顶部电磁锤振打','底部绕臂锤振打' => '底部绕臂锤振打','顶部绕臂锤底部绕臂锤振打' => '顶部绕臂锤+底部绕臂锤振打']
                        )->when('底部绕臂锤振打',function(StepForm $step){
                            $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                $table->text('电场阳打延迟时间(s)');
                                $table->text('电场阳打运行时间(s)');
                                $table->text('电场阳打停止时间(s)');
                            })->rules('required');
                        })->when('顶部绕臂锤底部绕臂锤振打',function(StepForm $step){
                            $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                $table->text('电场上阳打延迟时间(s)');
                                $table->text('电场上阳打运行时间(s)');
                                $table->text('电场上阳打停止时间(s)');
                                $table->text('电场下阳打延迟时间(s)');
                                $table->text('电场下阳打运行时间(s)');
                                $table->text('电场下阳打停止时间(s)');
                            })->rules('required');
                        })->default('顶部电磁锤振打');
                        
                        $step->radio('yinjzdxs','阴极振打形式')->options(
                            ['顶部电磁锤振打' => '顶部电磁锤振打','顶部传动侧部绕臂锤振打' => '顶部传动+侧部绕臂锤振打','侧部传动侧部绕臂锤振打' => '侧部传动+侧部绕臂锤振打','空气振打锤'=>'空气振打锤']
                        )->when('侧部传动侧部绕臂锤振打',function(StepForm $step){
                            $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                $table->text('电场上阴打延迟时间(s)');
                                $table->text('电场上阴打运行时间(s)');
                                $table->text('电场上阴打停止时间(s)');
                                $table->text('电场中阴打延迟时间(s)');
                                $table->text('电场中阴打运行时间(s)');
                                $table->text('电场中阴打停止时间(s)');
                                $table->text('电场下阴打延迟时间(s)');
                                $table->text('电场下阴打运行时间(s)');
                                $table->text('电场下阴打停止时间(s)');
                            })->rules('required');
                            $step->table('yinjzdjr', trans('阴极振打传动加热控制设置'),function ($table) {
                                $table->text('电场上转轴箱温度上限(℃)');
                                $table->text('电场上转轴箱温度下限(℃)');
                                $table->text('电场中转轴箱温度上限(℃)');
                                $table->text('电场中转轴箱温度下限(℃)');
                                $table->text('电场下转轴箱温度上限(℃)');
                                $table->text('电场下转轴箱温度下限(℃)');
                            })->rules('required');
                        })->when('顶部传动侧部绕臂锤振打',function(StepForm $step){
                            $step->table('yinjzdjr', trans('阴极振打传动加热控制设置'),function ($table) {
                                $table->text('电场转轴箱温度上限(℃)');
                                $table->text('电场转轴箱温度下限(℃)');
                            })->rules('required');
                        })->default('顶部电磁锤振打');

                    })->when('4',function(StepForm $step){

                        $step->radio('yangjzdxs','阳极振打形式')->options(
                            ['顶部电磁锤振打' => '顶部电磁锤振打','底部绕臂锤振打' => '底部绕臂锤振打','顶部绕臂锤底部绕臂锤振打' => '顶部绕臂锤+底部绕臂锤振打']
                        )->when('底部绕臂锤振打',function(StepForm $step){
                            $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                $table->text('电场阳打延迟时间(s)');
                                $table->text('电场阳打运行时间(s)');
                                $table->text('电场阳打停止时间(s)');
                            })->rules('required');
                        })->when('顶部绕臂锤底部绕臂锤振打',function(StepForm $step){
                            $step->table('yangjzdsx', trans('阳极振打时序'),function ($table) {
                                $table->text('电场上阳打延迟时间(s)');
                                $table->text('电场上阳打运行时间(s)');
                                $table->text('电场上阳打停止时间(s)');
                                $table->text('电场下阳打延迟时间(s)');
                                $table->text('电场下阳打运行时间(s)');
                                $table->text('电场下阳打停止时间(s)');
                            })->rules('required');
                        })->default('顶部电磁锤振打');

                        $step->radio('yinjzdxs','阴极振打形式')->options(
                            ['顶部电磁锤振打' => '顶部电磁锤振打','顶部传动+侧部绕臂锤振打' => '顶部传动侧部绕臂锤振打','侧部传动+侧部绕臂锤振打' => '侧部传动+侧部绕臂锤振打','空气振打锤'=>'空气振打锤']
                        )->when('顶部传动侧部绕臂锤振打',function(StepForm $step){
                            $step->table('yinjzdjr', trans('阴极振打传动加热控制设置'),function ($table) {
                                $table->text('电场转轴箱温度上限(℃)');
                                $table->text('电场转轴箱温度下限(℃)');
                            })->rules('required');
                        })->default('顶部电磁锤振打');
                    })->default('1');
                    // ->required()->help('<i style="color:red">注意填写 一般取值：1~3</i>')
                    
                    
                    
                    // $step->text('p2m',trans('电场有效长度(m),单位为:m'),'left')->required()->help('<i style="color:red">注意:单位为m</i>');
                    
                    $step->radio('p2a','电除尘器类型','left')->options(
                        ['干式电除尘器' => '干式电除尘器','湿式电除尘器' => '湿式电除尘器','转炉圆筒电除尘器' => '转炉圆筒电除尘器']
                    );
                    // $step->radio('p2n','阳极振打形式')->options(
                    //     ['顶部电磁锤振打' => '顶部电磁锤振打','底部绕臂锤振打' => '底部绕臂锤振打','顶部绕臂锤+底部绕臂锤振打' => '顶部绕臂锤+底部绕臂锤振打']
                    // )->required()->default('顶部电磁锤振打');
                    // $step->radio('p2o','阴极振打形式')->options(
                    //     ['顶部电磁锤振打' => '顶部电磁锤振打','顶部传动+侧部绕臂锤振打' => '顶部传动+侧部绕臂锤振打','侧部传动+侧部绕臂锤振打' => '侧部传动+侧部绕臂锤振打','空气振打锤'=>'空气振打锤']
                    // )->required()->default('顶部电磁锤振打');
                    $step->radio('yinjbwxs','阴极保温箱形式')->options(
                        ['小保温箱' => '小保温箱','箱梁' => '箱梁','大保温箱' => '大保温箱']
                    )->when('小保温箱',function(StepForm $step){
                        $step->table('xbwx', trans('保温箱加热控制设置'),function ($table) {
                            $table->text('电场瓷瓶温度上限(℃)')->required();
                            $table->text('电场瓷瓶温度下限(℃)')->required();
                        })->rules('required');
                    })->when('箱梁',function(StepForm $step){
                        $step->table('xl', trans('保温箱加热控制设置'),function ($table) {
                            $table->text('箱梁加热温度上限(℃)')->required();
                            $table->text('箱梁加热温度下限(℃)')->required();
                        })->rules('required');
                    })->when('大保温箱',function(StepForm $step){
                        $step->table('dbwx', trans('保温箱加热控制设置'),function ($table) {
                            $table->text('大保温箱温度上限(℃)')->required();
                            $table->text('大保温箱温度下限(℃)')->required();
                        })->rules('required');
                    })->default('小保温箱');

                    $step->radio('hdjr','灰斗加热器形式')->options(
                        ['电加热' => '电加热','蒸汽加热' => '蒸汽加热','电加热蒸汽加热' => '电加热+蒸汽加热']
                    )->when('电加热',function(StepForm $step){
                        $step->table('djr', trans('灰斗电加热上下温度设置'),function ($table) {
                            $table->text('名称')->required();
                            $table->text('电场灰斗温度上限(℃)')->required();
                            $table->text('电场灰斗温度下限(℃)')->required();
                        })->rules('required');
                    })->when('电加热蒸汽加热',function(StepForm $step){
                        $step->table('djrzqjr', trans('灰斗电加热上下温度设置'),function ($table) {
                            $table->text('名称')->required();
                            $table->text('电场灰斗温度上限(℃)')->required();
                            $table->text('电场灰斗温度下限(℃)')->required();
                        })->rules('required');
                    })->default('电加热');

                    $step->radio('p2s','灰斗料位计配置')->options(
                        ['低料位' => '低料位','低料位+高料位' => '低料位+高料位','低料位+高料位+高高料位' => '低料位+高料位+高高料位']
                    );
                })
                ->add('电除尘器初设运行及设置数据', function ($step) {
                    $step->table('p3a', trans('电除尘器空升时运行数据'),function ($table) {
                        $table->text('电场名称')->required();
                        $table->text('一次电压(V)')->required();
                        $table->text('一次电流(A)')->required();
                        $table->text('二次电压(kV)')->required();
                        $table->text('二次电流(mA)')->required();
                    })->rules('required');
                    $step->table('p3b', trans('电除尘器带烟气负载运行数据'),function ($table) {
                        $table->text('电场名称')->required();
                        $table->text('一次电压(V)')->required();
                        $table->text('一次电流(A)')->required();
                        $table->text('二次电压(kV)')->required();
                        $table->text('二次电流(mA)')->required();
                    })->rules('required');
                    // $p2n = session()->get('p2n');
                    // if($p2n=='yangda1'){
                    //     $step->table('p4a', trans('阳极振打时序'),function ($table) {
                    //         $table->text('电场阳打延迟时间(s)')->required();
                    //         $table->text('电场阳打运行时间(s)')->required();
                    //         $table->text('电场阳打停止时间(s)')->required();
                    //     })->rules('required');
                    // }
                    // if($p2n=='yangda2'){
                    //     $step->table('p4a', trans('阳极振打时序'),function ($table) {
                    //         $table->text('电场上阳打延迟时间(s)')->required();
                    //         $table->text('电场上阳打运行时间(s)')->required();
                    //         $table->text('电场上阳打停止时间(s)')->required();
                    //         $table->text('电场下阳打延迟时间(s)')->required();
                    //         $table->text('电场下阳打运行时间(s)')->required();
                    //         $table->text('电场下阳打停止时间(s)')->required();
                    //     })->rules('required');
                    // }
                    // if($p2n=='yinji1'){
                    //     $step->table('p4a', trans('阳极振打时序'),function ($table) {
                    //         $table->text('电场阴极振打延迟时间(s)')->required();
                    //         $table->text('电场阴极振打运行时间(s)')->required();
                    //         $table->text('电场阴极振打停止时间(s)')->required();
                    //     })->rules('required');
                    // }
                    // if($p2n=='yinji2'){
                    //     $step->table('p4a', trans('阳极振打时序'),function ($table) {
                    //         $table->text('电场上阴打延迟时间(s)')->required();
                    //         $table->text('电场上阴打运行时间(s)')->required();
                    //         $table->text('电场上阴打停止时间(s)')->required();
                    //         $table->text('电场下阴打延迟时间(s)')->required();
                    //         $table->text('电场下阴打运行时间(s)')->required();
                    //         $table->text('电场下阴打停止时间(s)')->required();
                    //     })->rules('required');
                    // }
                    // if($p2n=='yinji3'){
                    //     $step->table('p4a', trans('阳极振打时序'),function ($table) {
                    //         $table->text('电场上阴打延迟时间(s)')->required();
                    //         $table->text('电场上阴打运行时间(s)')->required();
                    //         $table->text('电场上阴打停止时间(s)')->required();
                    //         $table->text('电场中阴打延迟时间(s)')->required();
                    //         $table->text('电场中阴打运行时间(s)')->required();
                    //         $table->text('电场中阴打停止时间(s)')->required();
                    //         $table->text('电场下阴打延迟时间(s)')->required();
                    //         $table->text('电场下阴打运行时间(s)')->required();
                    //         $table->text('电场下阴打停止时间(s)')->required();
                    //     })->rules('required');
                    // }
                    // $p2q = session()->get('p2q');
                    // if($p2q == '小保温箱'){
                    //     $step->table('p5a', trans('保温箱加热控制设置'),function ($table) {
                    //         $table->text('电场瓷瓶温度上限(℃)')->required();
                    //         $table->text('电场瓷瓶温度下限(℃)')->required();
                    //     })->rules('required');
                    // }
                    // if($p2q == '箱梁'){
                    //     $step->table('p5a', trans('保温箱加热控制设置'),function ($table) {
                    //         $table->text('箱梁加热温度上限(℃)')->required();
                    //         $table->text('箱梁加热温度下限(℃)')->required();
                    //     })->rules('required');
                    // }
                    // if($p2q == '大保温箱'){
                    //     $step->table('p5a', trans('保温箱加热控制设置'),function ($table) {
                    //         $table->text('大保温箱温度上限(℃)')->required();
                    //         $table->text('大保温箱温度下限(℃)')->required();
                    //     })->rules('required');
                    // }
                    // $p2o = session()->get('p2o');
                    // if($p2o!=0){
                    //     $step->table('p6a', trans('阴极振打传动加热控制设置'),function ($table) {
                    //         $table->text('电场转轴箱温度上限(℃)')->required();
                    //         $table->text('电场转轴箱温度下限(℃)')->required();
                    //     })->rules('required');
                    // }
                    // $step->table('p7a', trans('灰斗加热控制设置'),function ($table) {
                    //     $table->text('名称')->required();
                    //     $table->text('设置值')->required();
                    // })->rules('required');
                    $step->table('p8a', trans('高压电源极线限制值'),function ($table) {
                        $table->text('电场名称')->required();
                        $table->text('二次电压限制值(kV)')->required();
                        $table->text('二次电流限制值(mA)')->required();
                        $table->text('导通角（输出比）限制值')->required();
                        $table->text('备注')->required();
                    })->rules('required');
                })
                ->add('附图', function ($step) {
                    $step->image('p9a', trans('电除尘器正面照片'))->autoUpload()->url('step/files');
                    $step->image('p9b', trans('电除尘器侧面照片(能看到阴阳极振打)'))->autoUpload()->url('step/files');
                    $step->image('p9c', trans('电除尘器输灰系统照片(能看清卸灰阀形式，输灰系统形式)'))->autoUpload()->url('step/files');
                    $step->image('p9d', trans('电除尘器顶部照片'))->autoUpload()->url('step/files');
                    $step->image('p9e', trans('电除尘器配电室照片'))->autoUpload()->url('step/files');
                    $step->image('p9f', trans('电除尘器高压柜铭牌'))->autoUpload()->url('step/files');
                    $step->image('p9g', trans('电除尘器各电场表头照片'))->autoUpload()->url('step/files');
                    $step->image('p9h', trans('上位机照片(能看出上位机软件类型及版本)'))->autoUpload()->url('step/files');
                    $step->image('p9i', trans('PLC柜照片(能看清面板布置)'))->autoUpload()->url('step/files');
                    $step->image('p9j', trans('PLC柜内PLC型号照片'))->autoUpload()->url('step/files');
                    $step->image('p9k', trans('高压柜进线照片(能看清进线形式及电缆大小)'))->autoUpload()->url('step/files');
                    $step->image('p9l', trans('高压出线照片(能看清出线电缆数量及截面大小)'))->autoUpload()->url('step/files');
                });
                // ->done(function () use ($form) {
                //     $resource = $form->getResource(0);
    
                //     $data = [
                //         'title'       => '操作成功',
                //         'description' => '恭喜您成为第10086位用户',
                //         'createUrl'   => $resource,
                //         'backUrl'     => $resource,
                //     ];
    
                //     return view('admin::form.done-step', $data);
                // });
        });
    }

    public function step(Request $request){
        $info = $request->all();
        // $res = InputStepForm::where('id',15)->first();
        // $a = json_decode($res,1);
        // Log::info(json_decode($a['content'],1));
        
        if(empty($info['CURRENT_VALIDATION_STEP'])&&$info['ALL_STEPS']==1){//提交
            // Log::info($info);
            unset($info['_file_']);
            unset($info['CURRENT_VALIDATION_STEP']);
            unset($info['ALL_STEPS']);
            unset($info['_token']);
            //断面积 序号8*（序号6/1000）*（序号7/1000）*序号4
            $stepsum = 0;
            if(isset($info['p2h'])){
                foreach($info['p2h'] as $key => $val){
                    $data['dsum'][$val['电场名称']] = $val['排数']*($info['p2f']/1000)*($info['p2g']/1000)*$info['p2d'];
                    //电场风速
                    $data['dcfs'][$val['电场名称']] = $info['p2i']/3600/$data['dsum'][$val['电场名称']];
                    $stepsum += $val['排数']*$val['有效长度(m)'];
                }
            }
            //总收尘面积  number_format()
            $data['scmj'] = $info['p2d']*($info['p2g']/1000)*$stepsum;
            //比集尘面积 公式=序号21/(序号9/3600)  总收尘面积/(处理烟气量/3600)
            $data['bjcmj'] = $data['scmj']*($info['p2i']/3600);
            $data['admin_id'] = Admin::user()->id;
            $data['name'] = $info['projectName'];
            $data['data'] = $info;
            // $data['content'] = json_encode($info);
            $insertData['content'] = json_encode($data);
            $insertData['name'] = $info['projectName'];
            $insertData['admin_id'] = Admin::user()->id;
            $insertData['created_at'] = date('Y-m-d H:i:s');
            InputStepForm::insert($insertData);
            return $this->form()->saving(function (Form $form) {
                // 清空缓存
                $form->multipleSteps()->flushStash();
                // 拦截保存操作
                return response(
                    $form->multipleSteps()
                        ->done()
                        ->render()
                );
            })->store();
        }
        if($info['CURRENT_VALIDATION_STEP']==1){
            // Log::info(222);
            
            // session()->put('step',$info);
            // if($info['p2n'] == '底部绕臂锤振打'){
            //     session()->put('p2n','yangda1');
            // }
            // if($info['p2n'] == '顶部绕臂锤+底部绕臂锤振打'){
            //     session()->put('p2n','yangda2');
            // }
            // if(($info['p2n'] == '顶部传动+侧部绕臂锤振打')||($info['p2p']==1)){
            //     session()->put('p2n','yinji1');
            // }
            // if(($info['p2n'] == '侧部传动+侧部绕臂锤振打')&&($info['p2p']==2)){
            //     session()->put('p2n','yinji2');
            // }
            // if(($info['p2n'] == '侧部传动+侧部绕臂锤振打')&&($info['p2p']==3)){
            //     session()->put('p2n','yinji3');
            // }
            // Log::info(session()->get('p2n'));
            // if($info['p2q'] == '小保温箱'){
            //     session()->put('p2q','小保温箱');
            // }
            // if($info['p2q'] == '箱梁'){
            //     session()->put('p2q','箱梁');
            // }
            // if($info['p2q'] == '大保温箱'){
            //     session()->put('p2q','大保温箱');
            // }
            // if($info['p2o'] == '顶部电磁锤振打'){ //不显示part6
            //     session()->put('p2o','0');
            // }
            // if($info['p2o'] == '顶部传动+侧部绕臂锤振打'){
            //     session()->put('p2o','1');
            // }
            // if(($info['p2o'] == '顶部传动+侧部绕臂锤振打')&&($info['p2p']==1)){
            //     session()->put('p2o','2');
            // }
            // if(($info['p2o'] == '顶部传动+侧部绕臂锤振打')&&($info['p2p']==2)){
            //     session()->put('p2o','3');
            // }
            // if(($info['p2o'] == '顶部传动+侧部绕臂锤振打')&&($info['p2p']==3)){
            //     session()->put('p2o','4');
            // }
            // if(($info['p2t'] == '电加热')||($info['p2t'] == '电加热+蒸汽加热')){
            //     session()->put('p2t','1');
            // }
            // if($info['p2t'] == '蒸汽加热'){ //不需要显示part7
            //     session()->put('p2t','2');
            // }  
        }
    }

    /**
     * 保存
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function store(Request $requset)
    {
        return $this->form()->saving(function (Form $form) {
            
            // 清空缓存
            $form->multipleSteps()->flushStash();
            // 拦截保存操作
            return response(
                $form->multipleSteps()
                    ->done()
                    ->render()
            );
        })->store();
    }
}